package com.zzh.staticTask;

import com.zzh.config.tackConfig.ApplicationContextUtil;
import com.zzh.entity.Result;
import com.zzh.service.mytask.MyTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @author wenrouyue
 * @FileName: MyTask
 * @description
 * @create 2022/11/25-10:15
 **/
@Configuration
@EnableScheduling
@Slf4j
public class MyTask {
    /**
     * 每分钟执行一次
     */
    private final String minutesCron = "0 * * * * ? ";
    /**
     * 每2小时执行一次
     */
    private final String hourCron = "0 0 0/2 * * ? ";
    /**
     * 每天12点执行
     */
    private final String dayCron = "0 0 0 * * ? ";

//    @Scheduled(cron = dayCron)
//    public void configureTasks() {
//        long start = System.currentTimeMillis();
//        log.info("clearHistoryVip_开始执行定时任务(清除过期会员)--------------" + start + "-----------------");
//        MyTaskService myTaskService = (MyTaskService) ApplicationContextUtil.getBean("MyTaskServiceImpl");
//        myTaskService.clearHistoryVip();
//        long end = System.currentTimeMillis();
//        log.info("clearHistoryVip_定时任务执行结束--------------" + end + "------------------");
//        log.info("clearHistoryVip_定时任务耗时--------------" + (end - start) + "------------------");
//    }
}
